package com.kenai.jbosh;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;

public final class BOSHClient
{
  private static final boolean ASSERTIONS = false;
  private static final int DEFAULT_EMPTY_REQUEST_DELAY = 100;
  private static final int DEFAULT_PAUSE_MARGIN = 500;
  private static final int EMPTY_REQUEST_DELAY = 0;
  private static final String ERROR = "error";
  private static final String INTERRUPTED = "Interrupted";
  private static final Logger LOG;
  private static final String NULL_LISTENER = "Listener may not b enull";
  private static final int PAUSE_MARGIN = 0;
  private static final String TERMINATE = "terminate";
  private static final String UNHANDLED = "Unhandled Exception";
  private final BOSHClientConfig cfg;
  private CMSessionParams cmParams;
  private final Set<BOSHClientConnListener> connListeners = new CopyOnWriteArraySet();
  private final Condition drained = this.lock.newCondition();
  private ScheduledFuture emptyRequestFuture;
  private final Runnable emptyRequestRunnable = new Runnable()
  {
    public void run()
    {
      BOSHClient.this.sendEmptyRequest();
    }
  };
  private final AtomicReference<ExchangeInterceptor> exchInterceptor = new AtomicReference();
  private Queue<HTTPExchange> exchanges = new LinkedList();
  private final HTTPSender httpSender = new ApacheHTTPSender();
  private final ReentrantLock lock = new ReentrantLock();
  private final Condition notEmpty = this.lock.newCondition();
  private final Condition notFull = this.lock.newCondition();
  private List<ComposableBody> pendingRequestAcks = new ArrayList();
  private SortedSet<Long> pendingResponseAcks = new TreeSet();
  private final Runnable procRunnable = new Runnable()
  {
    public void run()
    {
      BOSHClient.this.processMessages();
    }
  };
  private Thread procThread;
  private final RequestIDSequence requestIDSeq = new RequestIDSequence();
  private final Set<BOSHClientRequestListener> requestListeners = new CopyOnWriteArraySet();
  private Long responseAck = Long.valueOf(-1L);
  private final Set<BOSHClientResponseListener> responseListeners = new CopyOnWriteArraySet();
  private final ScheduledExecutorService schedExec = Executors.newSingleThreadScheduledExecutor();

  static
  {
    if (!BOSHClient.class.desiredAssertionStatus());
    String str;
    for (boolean bool1 = true; ; bool1 = false)
    {
      $assertionsDisabled = bool1;
      LOG = Logger.getLogger(BOSHClient.class.getName());
      EMPTY_REQUEST_DELAY = Integer.getInteger(BOSHClient.class.getName() + ".emptyRequestDelay", 100).intValue();
      PAUSE_MARGIN = Integer.getInteger(BOSHClient.class.getName() + ".pauseMargin", 500).intValue();
      str = BOSHClient.class.getSimpleName() + ".assertionsEnabled";
      if (System.getProperty(str) != null)
        break;
      boolean bool3 = $assertionsDisabled;
      bool2 = false;
      if (bool3)
        break label159;
      bool2 = true;
      if (bool2)
        break label159;
      throw new AssertionError();
    }
    boolean bool2 = Boolean.getBoolean(str);
    label159: ASSERTIONS = bool2;
  }

  private BOSHClient(BOSHClientConfig paramBOSHClientConfig)
  {
    this.cfg = paramBOSHClientConfig;
    init();
  }

  private void applyFrom(ComposableBody.Builder paramBuilder)
  {
    assertLocked();
    String str = this.cfg.getFrom();
    if (str != null)
      paramBuilder.setAttribute(Attributes.FROM, str);
  }

  private void applyResponseAcknowledgement(ComposableBody.Builder paramBuilder, long paramLong)
  {
    assertLocked();
    if (this.responseAck.equals(Long.valueOf(-1L)));
    Long localLong;
    do
    {
      return;
      localLong = Long.valueOf(paramLong - 1L);
    }
    while (this.responseAck.equals(localLong));
    paramBuilder.setAttribute(Attributes.ACK, this.responseAck.toString());
  }

  private void applyRoute(ComposableBody.Builder paramBuilder)
  {
    assertLocked();
    String str = this.cfg.getRoute();
    if (str != null)
      paramBuilder.setAttribute(Attributes.ROUTE, str);
  }

  private ComposableBody applySessionCreationRequest(long paramLong, ComposableBody paramComposableBody)
    throws BOSHException
  {
    assertLocked();
    ComposableBody.Builder localBuilder = paramComposableBody.rebuild();
    localBuilder.setAttribute(Attributes.TO, this.cfg.getTo());
    localBuilder.setAttribute(Attributes.XML_LANG, this.cfg.getLang());
    localBuilder.setAttribute(Attributes.VER, AttrVersion.getSupportedVersion().toString());
    localBuilder.setAttribute(Attributes.WAIT, "60");
    localBuilder.setAttribute(Attributes.HOLD, "1");
    localBuilder.setAttribute(Attributes.RID, Long.toString(paramLong));
    applyRoute(localBuilder);
    applyFrom(localBuilder);
    localBuilder.setAttribute(Attributes.ACK, "1");
    localBuilder.setAttribute(Attributes.SID, null);
    return localBuilder.build();
  }

  private ComposableBody applySessionData(long paramLong, ComposableBody paramComposableBody)
    throws BOSHException
  {
    assertLocked();
    ComposableBody.Builder localBuilder = paramComposableBody.rebuild();
    localBuilder.setAttribute(Attributes.SID, this.cmParams.getSessionID().toString());
    localBuilder.setAttribute(Attributes.RID, Long.toString(paramLong));
    applyResponseAcknowledgement(localBuilder, paramLong);
    return localBuilder.build();
  }

  private void assertLocked()
  {
    if ((ASSERTIONS) && (!this.lock.isHeldByCurrentThread()))
      throw new AssertionError("Lock is not held by current thread");
  }

  private void assertUnlocked()
  {
    if ((ASSERTIONS) && (this.lock.isHeldByCurrentThread()))
      throw new AssertionError("Lock is held by current thread");
  }

  private void blockUntilSendable(AbstractBody paramAbstractBody)
  {
    assertLocked();
    while (true)
    {
      if ((!isWorking()) || (isImmediatelySendable(paramAbstractBody)))
        return;
      try
      {
        this.notFull.await();
      }
      catch (InterruptedException localInterruptedException)
      {
        LOG.log(Level.FINEST, "Interrupted", localInterruptedException);
      }
    }
  }

  private void checkForTerminalBindingConditions(AbstractBody paramAbstractBody, int paramInt)
    throws BOSHException
  {
    TerminalBindingCondition localTerminalBindingCondition = getTerminalBindingCondition(paramInt, paramAbstractBody);
    if (localTerminalBindingCondition != null)
      throw new BOSHException("Terminal binding condition encountered: " + localTerminalBindingCondition.getCondition() + "  (" + localTerminalBindingCondition.getMessage() + ")");
  }

  private void clearEmptyRequest()
  {
    assertLocked();
    if (this.emptyRequestFuture != null)
    {
      this.emptyRequestFuture.cancel(false);
      this.emptyRequestFuture = null;
    }
  }

  public static BOSHClient create(BOSHClientConfig paramBOSHClientConfig)
  {
    if (paramBOSHClientConfig == null)
      throw new IllegalArgumentException("Client configuration may not be null");
    return new BOSHClient(paramBOSHClientConfig);
  }

  // ERROR //
  private void dispose(Throwable paramThrowable)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 449	com/kenai/jbosh/BOSHClient:assertUnlocked	()V
    //   4: aload_0
    //   5: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   8: invokevirtual 451	java/util/concurrent/locks/ReentrantLock:lock	()V
    //   11: aload_0
    //   12: getfield 453	com/kenai/jbosh/BOSHClient:procThread	Ljava/lang/Thread;
    //   15: astore_3
    //   16: aload_3
    //   17: ifnonnull +11 -> 28
    //   20: aload_0
    //   21: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   24: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   27: return
    //   28: aload_0
    //   29: aconst_null
    //   30: putfield 453	com/kenai/jbosh/BOSHClient:procThread	Ljava/lang/Thread;
    //   33: aload_0
    //   34: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   37: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   40: aload_1
    //   41: ifnonnull +102 -> 143
    //   44: aload_0
    //   45: invokespecial 459	com/kenai/jbosh/BOSHClient:fireConnectionClosed	()V
    //   48: aload_0
    //   49: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   52: invokevirtual 451	java/util/concurrent/locks/ReentrantLock:lock	()V
    //   55: aload_0
    //   56: invokespecial 461	com/kenai/jbosh/BOSHClient:clearEmptyRequest	()V
    //   59: aload_0
    //   60: aconst_null
    //   61: putfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   64: aload_0
    //   65: aconst_null
    //   66: putfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   69: aload_0
    //   70: aconst_null
    //   71: putfield 230	com/kenai/jbosh/BOSHClient:pendingResponseAcks	Ljava/util/SortedSet;
    //   74: aload_0
    //   75: aconst_null
    //   76: putfield 244	com/kenai/jbosh/BOSHClient:pendingRequestAcks	Ljava/util/List;
    //   79: aload_0
    //   80: getfield 181	com/kenai/jbosh/BOSHClient:notEmpty	Ljava/util/concurrent/locks/Condition;
    //   83: invokeinterface 464 1 0
    //   88: aload_0
    //   89: getfield 183	com/kenai/jbosh/BOSHClient:notFull	Ljava/util/concurrent/locks/Condition;
    //   92: invokeinterface 464 1 0
    //   97: aload_0
    //   98: getfield 185	com/kenai/jbosh/BOSHClient:drained	Ljava/util/concurrent/locks/Condition;
    //   101: invokeinterface 464 1 0
    //   106: aload_0
    //   107: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   110: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   113: aload_0
    //   114: getfield 202	com/kenai/jbosh/BOSHClient:httpSender	Lcom/kenai/jbosh/HTTPSender;
    //   117: invokeinterface 469 1 0
    //   122: aload_0
    //   123: getfield 220	com/kenai/jbosh/BOSHClient:schedExec	Ljava/util/concurrent/ScheduledExecutorService;
    //   126: invokeinterface 475 1 0
    //   131: pop
    //   132: return
    //   133: astore_2
    //   134: aload_0
    //   135: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   138: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   141: aload_2
    //   142: athrow
    //   143: aload_0
    //   144: aload_1
    //   145: invokespecial 478	com/kenai/jbosh/BOSHClient:fireConnectionClosedOnError	(Ljava/lang/Throwable;)V
    //   148: goto -100 -> 48
    //   151: astore 4
    //   153: aload_0
    //   154: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   157: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   160: aload 4
    //   162: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   11	16	133	finally
    //   28	33	133	finally
    //   55	106	151	finally
  }

  private void fireConnectionClosed()
  {
    assertUnlocked();
    BOSHClientConnEvent localBOSHClientConnEvent = null;
    Iterator localIterator = this.connListeners.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      BOSHClientConnListener localBOSHClientConnListener = (BOSHClientConnListener)localIterator.next();
      if (localBOSHClientConnEvent == null)
        localBOSHClientConnEvent = BOSHClientConnEvent.createConnectionClosedEvent(this);
      try
      {
        localBOSHClientConnListener.connectionEvent(localBOSHClientConnEvent);
      }
      catch (Exception localException)
      {
        LOG.log(Level.WARNING, "Unhandled Exception", localException);
      }
    }
  }

  private void fireConnectionClosedOnError(Throwable paramThrowable)
  {
    assertUnlocked();
    BOSHClientConnEvent localBOSHClientConnEvent = null;
    Iterator localIterator = this.connListeners.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      BOSHClientConnListener localBOSHClientConnListener = (BOSHClientConnListener)localIterator.next();
      if (localBOSHClientConnEvent == null)
        localBOSHClientConnEvent = BOSHClientConnEvent.createConnectionClosedOnErrorEvent(this, this.pendingRequestAcks, paramThrowable);
      try
      {
        localBOSHClientConnListener.connectionEvent(localBOSHClientConnEvent);
      }
      catch (Exception localException)
      {
        LOG.log(Level.WARNING, "Unhandled Exception", localException);
      }
    }
  }

  private void fireConnectionEstablished()
  {
    boolean bool1 = this.lock.isHeldByCurrentThread();
    if (bool1)
      this.lock.unlock();
    Object localObject1 = null;
    try
    {
      Iterator localIterator = this.connListeners.iterator();
      while (true)
      {
        boolean bool2 = localIterator.hasNext();
        if (!bool2)
          return;
        BOSHClientConnListener localBOSHClientConnListener = (BOSHClientConnListener)localIterator.next();
        if (localObject1 == null)
        {
          BOSHClientConnEvent localBOSHClientConnEvent = BOSHClientConnEvent.createConnectionEstablishedEvent(this);
          localObject1 = localBOSHClientConnEvent;
        }
        try
        {
          localBOSHClientConnListener.connectionEvent(localObject1);
        }
        catch (Exception localException)
        {
          LOG.log(Level.WARNING, "Unhandled Exception", localException);
        }
      }
    }
    finally
    {
      if (bool1)
        this.lock.lock();
    }
  }

  private void fireRequestSent(AbstractBody paramAbstractBody)
  {
    assertUnlocked();
    BOSHMessageEvent localBOSHMessageEvent = null;
    Iterator localIterator = this.requestListeners.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      BOSHClientRequestListener localBOSHClientRequestListener = (BOSHClientRequestListener)localIterator.next();
      if (localBOSHMessageEvent == null)
        localBOSHMessageEvent = BOSHMessageEvent.createRequestSentEvent(this, paramAbstractBody);
      try
      {
        localBOSHClientRequestListener.requestSent(localBOSHMessageEvent);
      }
      catch (Exception localException)
      {
        LOG.log(Level.WARNING, "Unhandled Exception", localException);
      }
    }
  }

  private void fireResponseReceived(AbstractBody paramAbstractBody)
  {
    assertUnlocked();
    BOSHMessageEvent localBOSHMessageEvent = null;
    Iterator localIterator = this.responseListeners.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      BOSHClientResponseListener localBOSHClientResponseListener = (BOSHClientResponseListener)localIterator.next();
      if (localBOSHMessageEvent == null)
        localBOSHMessageEvent = BOSHMessageEvent.createResponseReceivedEvent(this, paramAbstractBody);
      try
      {
        localBOSHClientResponseListener.responseReceived(localBOSHMessageEvent);
      }
      catch (Exception localException)
      {
        LOG.log(Level.WARNING, "Unhandled Exception", localException);
      }
    }
  }

  private long getDefaultEmptyRequestDelay()
  {
    assertLocked();
    AttrPolling localAttrPolling = this.cmParams.getPollingInterval();
    if (localAttrPolling == null)
      return EMPTY_REQUEST_DELAY;
    return localAttrPolling.getInMilliseconds();
  }

  private TerminalBindingCondition getTerminalBindingCondition(int paramInt, AbstractBody paramAbstractBody)
  {
    assertLocked();
    if (isTermination(paramAbstractBody))
      return TerminalBindingCondition.forString(paramAbstractBody.getAttribute(Attributes.CONDITION));
    if ((this.cmParams != null) && (this.cmParams.getVersion() == null))
      return TerminalBindingCondition.forHTTPResponseCode(paramInt);
    return null;
  }

  private void init()
  {
    assertUnlocked();
    this.lock.lock();
    try
    {
      this.httpSender.init(this.cfg);
      this.procThread = new Thread(this.procRunnable);
      this.procThread.setDaemon(true);
      this.procThread.setName(BOSHClient.class.getSimpleName() + "[" + System.identityHashCode(this) + "]: Receive thread");
      this.procThread.start();
      return;
    }
    finally
    {
      this.lock.unlock();
    }
  }

  private boolean isImmediatelySendable(AbstractBody paramAbstractBody)
  {
    boolean bool = true;
    assertLocked();
    if (this.cmParams == null)
      bool = this.exchanges.isEmpty();
    int i;
    do
    {
      AttrRequests localAttrRequests;
      do
      {
        return bool;
        localAttrRequests = this.cmParams.getRequests();
      }
      while (localAttrRequests == null);
      i = localAttrRequests.intValue();
    }
    while ((this.exchanges.size() < i) || ((this.exchanges.size() == i) && ((isTermination(paramAbstractBody)) || (isPause(paramAbstractBody)))));
    return false;
  }

  private static boolean isPause(AbstractBody paramAbstractBody)
  {
    return paramAbstractBody.getAttribute(Attributes.PAUSE) != null;
  }

  private static boolean isRecoverableBindingCondition(AbstractBody paramAbstractBody)
  {
    return "error".equals(paramAbstractBody.getAttribute(Attributes.TYPE));
  }

  private static boolean isTermination(AbstractBody paramAbstractBody)
  {
    return "terminate".equals(paramAbstractBody.getAttribute(Attributes.TYPE));
  }

  private boolean isWorking()
  {
    assertLocked();
    return this.procThread != null;
  }

  private HTTPExchange nextExchange()
  {
    assertUnlocked();
    Thread localThread = Thread.currentThread();
    HTTPExchange localHTTPExchange = null;
    this.lock.lock();
    try
    {
      while (true)
      {
        boolean bool = localThread.equals(this.procThread);
        if (!bool)
          return localHTTPExchange;
        localHTTPExchange = (HTTPExchange)this.exchanges.peek();
        if (localHTTPExchange == null);
        try
        {
          this.notEmpty.await();
          if (localHTTPExchange == null)
            continue;
        }
        catch (InterruptedException localInterruptedException)
        {
          while (true)
            LOG.log(Level.FINEST, "Interrupted", localInterruptedException);
        }
      }
    }
    finally
    {
      this.lock.unlock();
    }
  }

  // ERROR //
  private void processExchange(HTTPExchange paramHTTPExchange)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 449	com/kenai/jbosh/BOSHClient:assertUnlocked	()V
    //   4: aload_1
    //   5: invokevirtual 646	com/kenai/jbosh/HTTPExchange:getHTTPResponse	()Lcom/kenai/jbosh/HTTPResponse;
    //   8: astore 4
    //   10: aload 4
    //   12: invokeinterface 652 1 0
    //   17: astore 5
    //   19: aload 4
    //   21: invokeinterface 655 1 0
    //   26: istore 6
    //   28: aload_0
    //   29: aload 5
    //   31: invokespecial 657	com/kenai/jbosh/BOSHClient:fireResponseReceived	(Lcom/kenai/jbosh/AbstractBody;)V
    //   34: aload_1
    //   35: invokevirtual 660	com/kenai/jbosh/HTTPExchange:getRequest	()Lcom/kenai/jbosh/AbstractBody;
    //   38: astore 7
    //   40: aload_0
    //   41: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   44: invokevirtual 451	java/util/concurrent/locks/ReentrantLock:lock	()V
    //   47: aload_0
    //   48: getfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   51: ifnonnull +18 -> 69
    //   54: aload_0
    //   55: aload 7
    //   57: aload 5
    //   59: invokestatic 664	com/kenai/jbosh/CMSessionParams:fromSessionInit	(Lcom/kenai/jbosh/AbstractBody;Lcom/kenai/jbosh/AbstractBody;)Lcom/kenai/jbosh/CMSessionParams;
    //   62: putfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   65: aload_0
    //   66: invokespecial 666	com/kenai/jbosh/BOSHClient:fireConnectionEstablished	()V
    //   69: aload_0
    //   70: getfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   73: astore 14
    //   75: aload_0
    //   76: aload 5
    //   78: iload 6
    //   80: invokespecial 668	com/kenai/jbosh/BOSHClient:checkForTerminalBindingConditions	(Lcom/kenai/jbosh/AbstractBody;I)V
    //   83: aload 5
    //   85: invokestatic 554	com/kenai/jbosh/BOSHClient:isTermination	(Lcom/kenai/jbosh/AbstractBody;)Z
    //   88: ifeq +126 -> 214
    //   91: aload_0
    //   92: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   95: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   98: aload_0
    //   99: aconst_null
    //   100: invokespecial 670	com/kenai/jbosh/BOSHClient:dispose	(Ljava/lang/Throwable;)V
    //   103: aload_0
    //   104: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   107: invokevirtual 372	java/util/concurrent/locks/ReentrantLock:isHeldByCurrentThread	()Z
    //   110: ifeq +52 -> 162
    //   113: aload_0
    //   114: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   117: aload_1
    //   118: invokeinterface 673 2 0
    //   123: pop
    //   124: aload_0
    //   125: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   128: invokeinterface 607 1 0
    //   133: ifeq +13 -> 146
    //   136: aload_0
    //   137: aload_0
    //   138: aload 7
    //   140: invokespecial 677	com/kenai/jbosh/BOSHClient:processPauseRequest	(Lcom/kenai/jbosh/AbstractBody;)J
    //   143: invokespecial 681	com/kenai/jbosh/BOSHClient:scheduleEmptyRequest	(J)V
    //   146: aload_0
    //   147: getfield 183	com/kenai/jbosh/BOSHClient:notFull	Ljava/util/concurrent/locks/Condition;
    //   150: invokeinterface 464 1 0
    //   155: aload_0
    //   156: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   159: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   162: return
    //   163: astore_3
    //   164: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   167: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   170: ldc_w 683
    //   173: aload_3
    //   174: invokevirtual 406	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   177: aload_0
    //   178: aload_3
    //   179: invokespecial 670	com/kenai/jbosh/BOSHClient:dispose	(Ljava/lang/Throwable;)V
    //   182: return
    //   183: astore_2
    //   184: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   187: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   190: ldc 21
    //   192: aload_2
    //   193: invokevirtual 406	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   196: aload_0
    //   197: aload_2
    //   198: invokespecial 670	com/kenai/jbosh/BOSHClient:dispose	(Ljava/lang/Throwable;)V
    //   201: return
    //   202: astore 30
    //   204: aload_0
    //   205: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   208: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   211: aload 30
    //   213: athrow
    //   214: aload 5
    //   216: invokestatic 685	com/kenai/jbosh/BOSHClient:isRecoverableBindingCondition	(Lcom/kenai/jbosh/AbstractBody;)Z
    //   219: ifeq +411 -> 630
    //   222: aconst_null
    //   223: astore 15
    //   225: iconst_0
    //   226: ifne +21 -> 247
    //   229: new 241	java/util/ArrayList
    //   232: dup
    //   233: aload_0
    //   234: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   237: invokeinterface 617 1 0
    //   242: invokespecial 688	java/util/ArrayList:<init>	(I)V
    //   245: astore 15
    //   247: aload_0
    //   248: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   251: invokeinterface 689 1 0
    //   256: astore 16
    //   258: aload 16
    //   260: invokeinterface 491 1 0
    //   265: ifne +154 -> 419
    //   268: aload 15
    //   270: invokeinterface 692 1 0
    //   275: astore 18
    //   277: aload 18
    //   279: invokeinterface 491 1 0
    //   284: istore 19
    //   286: iload 19
    //   288: ifne +251 -> 539
    //   291: aload_0
    //   292: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   295: invokevirtual 372	java/util/concurrent/locks/ReentrantLock:isHeldByCurrentThread	()Z
    //   298: ifeq +52 -> 350
    //   301: aload_0
    //   302: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   305: aload_1
    //   306: invokeinterface 673 2 0
    //   311: pop
    //   312: aload_0
    //   313: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   316: invokeinterface 607 1 0
    //   321: ifeq +13 -> 334
    //   324: aload_0
    //   325: aload_0
    //   326: aload 7
    //   328: invokespecial 677	com/kenai/jbosh/BOSHClient:processPauseRequest	(Lcom/kenai/jbosh/AbstractBody;)J
    //   331: invokespecial 681	com/kenai/jbosh/BOSHClient:scheduleEmptyRequest	(J)V
    //   334: aload_0
    //   335: getfield 183	com/kenai/jbosh/BOSHClient:notFull	Ljava/util/concurrent/locks/Condition;
    //   338: invokeinterface 464 1 0
    //   343: aload_0
    //   344: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   347: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   350: aload 15
    //   352: ifnull -190 -> 162
    //   355: aload 15
    //   357: invokeinterface 692 1 0
    //   362: astore 22
    //   364: aload 22
    //   366: invokeinterface 491 1 0
    //   371: ifeq -209 -> 162
    //   374: aload 22
    //   376: invokeinterface 495 1 0
    //   381: checkcast 640	com/kenai/jbosh/HTTPExchange
    //   384: astore 23
    //   386: aload 23
    //   388: aload_0
    //   389: getfield 202	com/kenai/jbosh/BOSHClient:httpSender	Lcom/kenai/jbosh/HTTPSender;
    //   392: aload 14
    //   394: aload 23
    //   396: invokevirtual 660	com/kenai/jbosh/HTTPExchange:getRequest	()Lcom/kenai/jbosh/AbstractBody;
    //   399: invokeinterface 696 3 0
    //   404: invokevirtual 700	com/kenai/jbosh/HTTPExchange:setHTTPResponse	(Lcom/kenai/jbosh/HTTPResponse;)V
    //   407: aload_0
    //   408: aload 23
    //   410: invokevirtual 660	com/kenai/jbosh/HTTPExchange:getRequest	()Lcom/kenai/jbosh/AbstractBody;
    //   413: invokespecial 702	com/kenai/jbosh/BOSHClient:fireRequestSent	(Lcom/kenai/jbosh/AbstractBody;)V
    //   416: goto -52 -> 364
    //   419: aload 15
    //   421: new 640	com/kenai/jbosh/HTTPExchange
    //   424: dup
    //   425: aload 16
    //   427: invokeinterface 495 1 0
    //   432: checkcast 640	com/kenai/jbosh/HTTPExchange
    //   435: invokevirtual 660	com/kenai/jbosh/HTTPExchange:getRequest	()Lcom/kenai/jbosh/AbstractBody;
    //   438: invokespecial 704	com/kenai/jbosh/HTTPExchange:<init>	(Lcom/kenai/jbosh/AbstractBody;)V
    //   441: invokeinterface 707 2 0
    //   446: pop
    //   447: goto -189 -> 258
    //   450: astore 11
    //   452: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   455: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   458: ldc_w 709
    //   461: aload 11
    //   463: invokevirtual 406	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   466: aload_0
    //   467: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   470: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   473: aload_0
    //   474: aload 11
    //   476: invokespecial 670	com/kenai/jbosh/BOSHClient:dispose	(Ljava/lang/Throwable;)V
    //   479: aload_0
    //   480: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   483: invokevirtual 372	java/util/concurrent/locks/ReentrantLock:isHeldByCurrentThread	()Z
    //   486: ifeq -324 -> 162
    //   489: aload_0
    //   490: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   493: aload_1
    //   494: invokeinterface 673 2 0
    //   499: pop
    //   500: aload_0
    //   501: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   504: invokeinterface 607 1 0
    //   509: ifeq +13 -> 522
    //   512: aload_0
    //   513: aload_0
    //   514: aload 7
    //   516: invokespecial 677	com/kenai/jbosh/BOSHClient:processPauseRequest	(Lcom/kenai/jbosh/AbstractBody;)J
    //   519: invokespecial 681	com/kenai/jbosh/BOSHClient:scheduleEmptyRequest	(J)V
    //   522: aload_0
    //   523: getfield 183	com/kenai/jbosh/BOSHClient:notFull	Ljava/util/concurrent/locks/Condition;
    //   526: invokeinterface 464 1 0
    //   531: aload_0
    //   532: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   535: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   538: return
    //   539: aload 18
    //   541: invokeinterface 495 1 0
    //   546: checkcast 640	com/kenai/jbosh/HTTPExchange
    //   549: astore 20
    //   551: aload_0
    //   552: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   555: aload 20
    //   557: invokeinterface 710 2 0
    //   562: pop
    //   563: goto -286 -> 277
    //   566: astore 8
    //   568: aload_0
    //   569: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   572: invokevirtual 372	java/util/concurrent/locks/ReentrantLock:isHeldByCurrentThread	()Z
    //   575: ifeq +52 -> 627
    //   578: aload_0
    //   579: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   582: aload_1
    //   583: invokeinterface 673 2 0
    //   588: pop
    //   589: aload_0
    //   590: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   593: invokeinterface 607 1 0
    //   598: ifeq +13 -> 611
    //   601: aload_0
    //   602: aload_0
    //   603: aload 7
    //   605: invokespecial 677	com/kenai/jbosh/BOSHClient:processPauseRequest	(Lcom/kenai/jbosh/AbstractBody;)J
    //   608: invokespecial 681	com/kenai/jbosh/BOSHClient:scheduleEmptyRequest	(J)V
    //   611: aload_0
    //   612: getfield 183	com/kenai/jbosh/BOSHClient:notFull	Ljava/util/concurrent/locks/Condition;
    //   615: invokeinterface 464 1 0
    //   620: aload_0
    //   621: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   624: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   627: aload 8
    //   629: athrow
    //   630: aload_0
    //   631: aload 7
    //   633: aload 5
    //   635: invokespecial 714	com/kenai/jbosh/BOSHClient:processRequestAcknowledgements	(Lcom/kenai/jbosh/AbstractBody;Lcom/kenai/jbosh/AbstractBody;)V
    //   638: aload_0
    //   639: aload 7
    //   641: invokespecial 717	com/kenai/jbosh/BOSHClient:processResponseAcknowledgementData	(Lcom/kenai/jbosh/AbstractBody;)V
    //   644: aload_0
    //   645: aload 5
    //   647: invokespecial 721	com/kenai/jbosh/BOSHClient:processResponseAcknowledgementReport	(Lcom/kenai/jbosh/AbstractBody;)Lcom/kenai/jbosh/HTTPExchange;
    //   650: astore 26
    //   652: aconst_null
    //   653: astore 15
    //   655: aload 26
    //   657: ifnull -366 -> 291
    //   660: aconst_null
    //   661: astore 15
    //   663: iconst_0
    //   664: ifne -373 -> 291
    //   667: new 241	java/util/ArrayList
    //   670: dup
    //   671: iconst_1
    //   672: invokespecial 688	java/util/ArrayList:<init>	(I)V
    //   675: astore 27
    //   677: aload 27
    //   679: aload 26
    //   681: invokeinterface 707 2 0
    //   686: pop
    //   687: aload_0
    //   688: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   691: aload 26
    //   693: invokeinterface 710 2 0
    //   698: pop
    //   699: aload 27
    //   701: astore 15
    //   703: goto -412 -> 291
    //   706: astore 12
    //   708: aload_0
    //   709: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   712: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   715: aload 12
    //   717: athrow
    //   718: astore 9
    //   720: aload_0
    //   721: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   724: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   727: aload 9
    //   729: athrow
    //   730: astore 24
    //   732: aload_0
    //   733: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   736: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   739: aload 24
    //   741: athrow
    //   742: astore 8
    //   744: goto -176 -> 568
    //   747: astore 11
    //   749: goto -297 -> 452
    //
    // Exception table:
    //   from	to	target	type
    //   4	28	163	com/kenai/jbosh/BOSHException
    //   4	28	183	java/lang/InterruptedException
    //   113	146	202	finally
    //   146	155	202	finally
    //   47	69	450	com/kenai/jbosh/BOSHException
    //   69	103	450	com/kenai/jbosh/BOSHException
    //   214	222	450	com/kenai/jbosh/BOSHException
    //   229	247	450	com/kenai/jbosh/BOSHException
    //   247	258	450	com/kenai/jbosh/BOSHException
    //   258	277	450	com/kenai/jbosh/BOSHException
    //   277	286	450	com/kenai/jbosh/BOSHException
    //   419	447	450	com/kenai/jbosh/BOSHException
    //   539	563	450	com/kenai/jbosh/BOSHException
    //   630	652	450	com/kenai/jbosh/BOSHException
    //   667	677	450	com/kenai/jbosh/BOSHException
    //   47	69	566	finally
    //   69	103	566	finally
    //   214	222	566	finally
    //   229	247	566	finally
    //   247	258	566	finally
    //   258	277	566	finally
    //   277	286	566	finally
    //   419	447	566	finally
    //   452	479	566	finally
    //   539	563	566	finally
    //   630	652	566	finally
    //   667	677	566	finally
    //   489	522	706	finally
    //   522	531	706	finally
    //   578	611	718	finally
    //   611	620	718	finally
    //   301	334	730	finally
    //   334	343	730	finally
    //   677	699	742	finally
    //   677	699	747	com/kenai/jbosh/BOSHException
  }

  // ERROR //
  private void processMessages()
  {
    // Byte code:
    //   0: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   3: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   6: ldc_w 723
    //   9: invokevirtual 726	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   12: aload_0
    //   13: invokespecial 728	com/kenai/jbosh/BOSHClient:nextExchange	()Lcom/kenai/jbosh/HTTPExchange;
    //   16: astore_2
    //   17: aload_2
    //   18: astore_3
    //   19: aload_3
    //   20: ifnonnull +16 -> 36
    //   23: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   26: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   29: ldc_w 730
    //   32: invokevirtual 726	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   35: return
    //   36: aload_0
    //   37: getfield 207	com/kenai/jbosh/BOSHClient:exchInterceptor	Ljava/util/concurrent/atomic/AtomicReference;
    //   40: invokevirtual 733	java/util/concurrent/atomic/AtomicReference:get	()Ljava/lang/Object;
    //   43: checkcast 735	com/kenai/jbosh/BOSHClient$ExchangeInterceptor
    //   46: astore 4
    //   48: aload 4
    //   50: ifnull +106 -> 156
    //   53: aload 4
    //   55: aload_3
    //   56: invokevirtual 739	com/kenai/jbosh/BOSHClient$ExchangeInterceptor:interceptExchange	(Lcom/kenai/jbosh/HTTPExchange;)Lcom/kenai/jbosh/HTTPExchange;
    //   59: astore 5
    //   61: aload 5
    //   63: ifnonnull +101 -> 164
    //   66: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   69: getstatic 742	java/util/logging/Level:FINE	Ljava/util/logging/Level;
    //   72: new 101	java/lang/StringBuilder
    //   75: dup
    //   76: ldc_w 744
    //   79: invokespecial 111	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   82: aload_3
    //   83: invokevirtual 660	com/kenai/jbosh/HTTPExchange:getRequest	()Lcom/kenai/jbosh/AbstractBody;
    //   86: getstatic 341	com/kenai/jbosh/Attributes:RID	Lcom/kenai/jbosh/BodyQName;
    //   89: invokevirtual 563	com/kenai/jbosh/AbstractBody:getAttribute	(Lcom/kenai/jbosh/BodyQName;)Ljava/lang/String;
    //   92: invokevirtual 117	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   95: invokevirtual 120	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   98: invokevirtual 726	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   101: aload_0
    //   102: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   105: invokevirtual 451	java/util/concurrent/locks/ReentrantLock:lock	()V
    //   108: aload_0
    //   109: getfield 225	com/kenai/jbosh/BOSHClient:exchanges	Ljava/util/Queue;
    //   112: aload_3
    //   113: invokeinterface 673 2 0
    //   118: pop
    //   119: aload_0
    //   120: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   123: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   126: goto -114 -> 12
    //   129: astore_1
    //   130: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   133: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   136: ldc_w 730
    //   139: invokevirtual 726	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   142: aload_1
    //   143: athrow
    //   144: astore 6
    //   146: aload_0
    //   147: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   150: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   153: aload 6
    //   155: athrow
    //   156: aload_0
    //   157: aload_3
    //   158: invokespecial 746	com/kenai/jbosh/BOSHClient:processExchange	(Lcom/kenai/jbosh/HTTPExchange;)V
    //   161: goto -149 -> 12
    //   164: aload 5
    //   166: astore_3
    //   167: goto -11 -> 156
    //
    // Exception table:
    //   from	to	target	type
    //   12	17	129	finally
    //   36	48	129	finally
    //   53	61	129	finally
    //   66	108	129	finally
    //   119	126	129	finally
    //   146	156	129	finally
    //   156	161	129	finally
    //   108	119	144	finally
  }

  private long processPauseRequest(AbstractBody paramAbstractBody)
  {
    assertLocked();
    if ((this.cmParams != null) && (this.cmParams.getMaxPause() != null))
      try
      {
        AttrPause localAttrPause = AttrPause.createFromString(paramAbstractBody.getAttribute(Attributes.PAUSE));
        if (localAttrPause != null)
        {
          long l = localAttrPause.getInMilliseconds() - PAUSE_MARGIN;
          if (l < 0L)
          {
            int i = EMPTY_REQUEST_DELAY;
            l = i;
          }
          return l;
        }
      }
      catch (BOSHException localBOSHException)
      {
        LOG.log(Level.FINEST, "Could not extract", localBOSHException);
      }
    return getDefaultEmptyRequestDelay();
  }

  private void processRequestAcknowledgements(AbstractBody paramAbstractBody1, AbstractBody paramAbstractBody2)
  {
    assertLocked();
    if (!this.cmParams.isAckingRequests());
    while (paramAbstractBody2.getAttribute(Attributes.REPORT) != null)
      return;
    String str = paramAbstractBody2.getAttribute(Attributes.ACK);
    if (str == null);
    for (Long localLong = Long.valueOf(Long.parseLong(paramAbstractBody1.getAttribute(Attributes.RID))); ; localLong = Long.valueOf(Long.parseLong(str)))
    {
      if (LOG.isLoggable(Level.FINEST))
        LOG.finest("Removing pending acks up to: " + localLong);
      Iterator localIterator = this.pendingRequestAcks.iterator();
      while (localIterator.hasNext())
        if (Long.valueOf(Long.parseLong(((AbstractBody)localIterator.next()).getAttribute(Attributes.RID))).compareTo(localLong) <= 0)
          localIterator.remove();
      break;
    }
  }

  private void processResponseAcknowledgementData(AbstractBody paramAbstractBody)
  {
    assertLocked();
    Long localLong1 = Long.valueOf(Long.parseLong(paramAbstractBody.getAttribute(Attributes.RID)));
    if (this.responseAck.equals(Long.valueOf(-1L)))
      this.responseAck = localLong1;
    while (true)
    {
      return;
      this.pendingResponseAcks.add(localLong1);
      for (Long localLong2 = this.responseAck; localLong2.equals(this.pendingResponseAcks.first()); localLong2 = Long.valueOf(1L + localLong2.longValue()))
      {
        this.responseAck = localLong2;
        this.pendingResponseAcks.remove(localLong2);
      }
    }
  }

  private HTTPExchange processResponseAcknowledgementReport(AbstractBody paramAbstractBody)
    throws BOSHException
  {
    assertLocked();
    String str = paramAbstractBody.getAttribute(Attributes.REPORT);
    if (str == null)
      return null;
    Long localLong1 = Long.valueOf(Long.parseLong(str));
    Long localLong2 = Long.valueOf(Long.parseLong(paramAbstractBody.getAttribute(Attributes.TIME)));
    if (LOG.isLoggable(Level.FINE))
      LOG.fine("Received report of missing request (RID=" + localLong1 + ", time=" + localLong2 + "ms)");
    Iterator localIterator = this.pendingRequestAcks.iterator();
    Object localObject = null;
    while (true)
    {
      if ((!localIterator.hasNext()) || (localObject != null))
      {
        if (localObject != null)
          break;
        throw new BOSHException("Report of missing message with RID '" + str + "' but local copy of that request was not found");
      }
      AbstractBody localAbstractBody = (AbstractBody)localIterator.next();
      if (localLong1.equals(Long.valueOf(Long.parseLong(localAbstractBody.getAttribute(Attributes.RID)))))
        localObject = localAbstractBody;
    }
    HTTPExchange localHTTPExchange = new HTTPExchange(localObject);
    this.exchanges.add(localHTTPExchange);
    this.notEmpty.signalAll();
    return localHTTPExchange;
  }

  private void scheduleEmptyRequest(long paramLong)
  {
    assertLocked();
    if (paramLong < 0L)
      throw new IllegalArgumentException("Empty request delay must be >= 0 (was: " + paramLong + ")");
    clearEmptyRequest();
    if (!isWorking())
      return;
    if (LOG.isLoggable(Level.FINER))
      LOG.finer("Scheduling empty request in " + paramLong + "ms");
    try
    {
      this.emptyRequestFuture = this.schedExec.schedule(this.emptyRequestRunnable, paramLong, TimeUnit.MILLISECONDS);
      this.drained.signalAll();
      return;
    }
    catch (RejectedExecutionException localRejectedExecutionException)
    {
      while (true)
        LOG.log(Level.FINEST, "Could not schedule empty request", localRejectedExecutionException);
    }
  }

  private void sendEmptyRequest()
  {
    assertUnlocked();
    LOG.finest("Sending empty request");
    try
    {
      send(ComposableBody.builder().build());
      return;
    }
    catch (BOSHException localBOSHException)
    {
      dispose(localBOSHException);
    }
  }

  public void addBOSHClientConnListener(BOSHClientConnListener paramBOSHClientConnListener)
  {
    if (paramBOSHClientConnListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.connListeners.add(paramBOSHClientConnListener);
  }

  public void addBOSHClientRequestListener(BOSHClientRequestListener paramBOSHClientRequestListener)
  {
    if (paramBOSHClientRequestListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.requestListeners.add(paramBOSHClientRequestListener);
  }

  public void addBOSHClientResponseListener(BOSHClientResponseListener paramBOSHClientResponseListener)
  {
    if (paramBOSHClientResponseListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.responseListeners.add(paramBOSHClientResponseListener);
  }

  public void close()
  {
    dispose(new BOSHException("Session explicitly closed by caller"));
  }

  public void disconnect()
    throws BOSHException
  {
    disconnect(ComposableBody.builder().build());
  }

  public void disconnect(ComposableBody paramComposableBody)
    throws BOSHException
  {
    if (paramComposableBody == null)
      throw new IllegalArgumentException("Message body may not be null");
    ComposableBody.Builder localBuilder = paramComposableBody.rebuild();
    localBuilder.setAttribute(Attributes.TYPE, "terminate");
    send(localBuilder.build());
  }

  void drain()
  {
    this.lock.lock();
    try
    {
      LOG.finest("Waiting while draining...");
      while (true)
      {
        if ((!isWorking()) || ((this.emptyRequestFuture != null) && (!this.emptyRequestFuture.isDone())))
        {
          LOG.finest("Drained");
          return;
        }
        try
        {
          this.drained.await();
        }
        catch (InterruptedException localInterruptedException)
        {
          LOG.log(Level.FINEST, "Interrupted", localInterruptedException);
        }
      }
    }
    finally
    {
      this.lock.unlock();
    }
  }

  public BOSHClientConfig getBOSHClientConfig()
  {
    return this.cfg;
  }

  CMSessionParams getCMSessionParams()
  {
    this.lock.lock();
    try
    {
      CMSessionParams localCMSessionParams = this.cmParams;
      return localCMSessionParams;
    }
    finally
    {
      this.lock.unlock();
    }
  }

  // ERROR //
  public boolean pause()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 449	com/kenai/jbosh/BOSHClient:assertUnlocked	()V
    //   4: aload_0
    //   5: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   8: invokevirtual 451	java/util/concurrent/locks/ReentrantLock:lock	()V
    //   11: aload_0
    //   12: getfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   15: astore_2
    //   16: aload_2
    //   17: ifnonnull +12 -> 29
    //   20: aload_0
    //   21: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   24: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   27: iconst_0
    //   28: ireturn
    //   29: aload_0
    //   30: getfield 358	com/kenai/jbosh/BOSHClient:cmParams	Lcom/kenai/jbosh/CMSessionParams;
    //   33: invokevirtual 750	com/kenai/jbosh/CMSessionParams:getMaxPause	()Lcom/kenai/jbosh/AttrMaxPause;
    //   36: astore_3
    //   37: aload_3
    //   38: ifnull -18 -> 20
    //   41: aload_0
    //   42: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   45: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   48: aload_0
    //   49: invokestatic 849	com/kenai/jbosh/ComposableBody:builder	()Lcom/kenai/jbosh/ComposableBody$Builder;
    //   52: getstatic 623	com/kenai/jbosh/Attributes:PAUSE	Lcom/kenai/jbosh/BodyQName;
    //   55: aload_3
    //   56: invokevirtual 883	com/kenai/jbosh/AttrMaxPause:toString	()Ljava/lang/String;
    //   59: invokevirtual 279	com/kenai/jbosh/ComposableBody$Builder:setAttribute	(Lcom/kenai/jbosh/BodyQName;Ljava/lang/String;)Lcom/kenai/jbosh/ComposableBody$Builder;
    //   62: invokevirtual 355	com/kenai/jbosh/ComposableBody$Builder:build	()Lcom/kenai/jbosh/ComposableBody;
    //   65: invokevirtual 852	com/kenai/jbosh/BOSHClient:send	(Lcom/kenai/jbosh/ComposableBody;)V
    //   68: iconst_1
    //   69: ireturn
    //   70: astore_1
    //   71: aload_0
    //   72: getfield 175	com/kenai/jbosh/BOSHClient:lock	Ljava/util/concurrent/locks/ReentrantLock;
    //   75: invokevirtual 456	java/util/concurrent/locks/ReentrantLock:unlock	()V
    //   78: aload_1
    //   79: athrow
    //   80: astore 4
    //   82: getstatic 99	com/kenai/jbosh/BOSHClient:LOG	Ljava/util/logging/Logger;
    //   85: getstatic 402	java/util/logging/Level:FINEST	Ljava/util/logging/Level;
    //   88: ldc_w 885
    //   91: aload 4
    //   93: invokevirtual 406	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   96: goto -28 -> 68
    //
    // Exception table:
    //   from	to	target	type
    //   11	16	70	finally
    //   29	37	70	finally
    //   48	68	80	com/kenai/jbosh/BOSHException
  }

  public void removeBOSHClientConnListener(BOSHClientConnListener paramBOSHClientConnListener)
  {
    if (paramBOSHClientConnListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.connListeners.remove(paramBOSHClientConnListener);
  }

  public void removeBOSHClientRequestListener(BOSHClientRequestListener paramBOSHClientRequestListener)
  {
    if (paramBOSHClientRequestListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.requestListeners.remove(paramBOSHClientRequestListener);
  }

  public void removeBOSHClientResponseListener(BOSHClientResponseListener paramBOSHClientResponseListener)
  {
    if (paramBOSHClientResponseListener == null)
      throw new IllegalArgumentException("Listener may not b enull");
    this.responseListeners.remove(paramBOSHClientResponseListener);
  }

  public void send(ComposableBody paramComposableBody)
    throws BOSHException
  {
    assertUnlocked();
    if (paramComposableBody == null)
      throw new IllegalArgumentException("Message body may not be null");
    this.lock.lock();
    try
    {
      blockUntilSendable(paramComposableBody);
      if ((!isWorking()) && (!isTermination(paramComposableBody)))
        throw new BOSHException("Cannot send message when session is closed");
    }
    finally
    {
      this.lock.unlock();
    }
    long l = this.requestIDSeq.getNextRID();
    CMSessionParams localCMSessionParams = this.cmParams;
    ComposableBody localComposableBody;
    if ((localCMSessionParams == null) && (this.exchanges.isEmpty()))
      localComposableBody = applySessionCreationRequest(l, paramComposableBody);
    while (true)
    {
      HTTPExchange localHTTPExchange = new HTTPExchange(localComposableBody);
      this.exchanges.add(localHTTPExchange);
      this.notEmpty.signalAll();
      clearEmptyRequest();
      this.lock.unlock();
      AbstractBody localAbstractBody = localHTTPExchange.getRequest();
      localHTTPExchange.setHTTPResponse(this.httpSender.send(localCMSessionParams, localAbstractBody));
      fireRequestSent(localAbstractBody);
      return;
      localComposableBody = applySessionData(l, paramComposableBody);
      if (this.cmParams.isAckingRequests())
        this.pendingRequestAcks.add(localComposableBody);
    }
  }

  void setExchangeInterceptor(ExchangeInterceptor paramExchangeInterceptor)
  {
    this.exchInterceptor.set(paramExchangeInterceptor);
  }

  static abstract class ExchangeInterceptor
  {
    abstract HTTPExchange interceptExchange(HTTPExchange paramHTTPExchange);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.kenai.jbosh.BOSHClient
 * JD-Core Version:    0.6.2
 */